// server/models/healthKnowledge.js
module.exports = (sequelize, DataTypes) => {
  const HealthKnowledge = sequelize.define('HealthKnowledge', {
    id: {
      type: DataTypes.INTEGER,
      primaryKey: true,
      autoIncrement: true
    },
    title: {
      type: DataTypes.STRING,
      allowNull: false,
      comment: '标题'
    },
    content: {
      type: DataTypes.TEXT,
      allowNull: false,
      comment: '内容'
    },
    category: {
      type: DataTypes.ENUM('disease', 'diet', 'exercise', 'medication', 'prevention', 'other'),
      defaultValue: 'other',
      comment: '分类：疾病、饮食、运动、用药、预防、其他'
    },
    tags: {
      type: DataTypes.STRING,
      allowNull: true,
      comment: '标签，多个标签用逗号分隔'
    },
    cover_image: {
      type: DataTypes.STRING,
      allowNull: true,
      comment: '封面图片URL'
    },
    author: {
      type: DataTypes.STRING,
      allowNull: true,
      comment: '作者'
    },
    source: {
      type: DataTypes.STRING,
      allowNull: true,
      comment: '来源'
    },
    view_count: {
      type: DataTypes.INTEGER,
      defaultValue: 0,
      comment: '浏览次数'
    },
    like_count: {
      type: DataTypes.INTEGER,
      defaultValue: 0,
      comment: '点赞次数'
    },
    publish_time: {
      type: DataTypes.DATE,
      defaultValue: DataTypes.NOW,
      comment: '发布时间'
    },
    status: {
      type: DataTypes.ENUM('draft', 'published', 'archived'),
      defaultValue: 'published',
      comment: '状态：草稿、已发布、已归档'
    },
    summary: {
      type: DataTypes.TEXT,
      allowNull: true,
      comment: '摘要'
    }
  }, {
    tableName: 'health_knowledge',
    timestamps: true,
    paranoid: true
  });

  return HealthKnowledge;
}; 